package practiceProjects.NoMarkdown;

import java.io.*;

/**
 * @Project ：learn_java
 * @File ：NoMarkdown.java
 * @IDE ：IntelliJ IDEA
 * @Author ：自由如风间
 * @Date ：2025/3/10 17:00
 * @Description ：删除md文件特有的标记符，即将#*-符号替换为空字符
 * @WhyICreateThis: 写IT项目管理实验报告需要，把ai给我的答案删去md格式，方便粘贴到报告里
 */

public class NoMarkdown {
    public static void main(String[] args) {
        String srcPath = "src/practiceProjects/NoMarkdown/sourceFile.txt";
        String outPath = "src/practiceProjects/NoMarkdown/out.txt";


        try (BufferedReader reader = new BufferedReader(new FileReader(srcPath));
             BufferedWriter writer = new BufferedWriter(new FileWriter(outPath))) {
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.replaceAll("[*#]", "");
                // 优化格式，因为- 作为分点会向内缩进
                line = line.replaceAll("-", "  ");
                writer.write(line);
                writer.newLine(); // 添加换行符
            }
            System.out.println("文件操作完成，已保存至" + outPath);
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("程序出错，已停止！");
        }
    }
}
